<template>
    <div>
      <van-nav-bar title="销售合同行" />
      <van-form>
        <van-cell-group inset>
        <div>
            <van-field
            v-model="contractDetail.contractDetailNum"
            name="合同行号"
            label="合同行号"
            placeholder="合同行号"
            :rules="[{ required: isEdit, message: '请填写合同行号' }]"
          />
          <van-field
            v-model="contractDetail.productSize"
            name="产品规格"
            label="产品规格"
            placeholder="产品规格"
            :rules="[{ required: isEdit, message: '请填写产品规格' }]"
          />
            <van-field
            v-model="contractDetail.quantity"
            name="数量"
            label="数量"
            placeholder="数量"
            :rules="[{ required: isEdit, message: '请填写数量' }]"
          />
          <van-field
            v-model="contractDetail.unit"
            name="单位"
            label="单位"
            placeholder="单位"
            :rules="[{ required: isEdit, message: '请填写单位' }]"
          />    <van-field
            v-model="contractDetail.unitPrice"
            name="单价"
            label="单价"
            placeholder="单价"
            :rules="[{ required: isEdit, message: '请填写单价' }]"
          />    <van-field
            v-model="contractDetail.unitRebate"
            name="单位佣金/返利"
            label="单位佣金/返利"
            placeholder="单位佣金/返利"
            :rules="[{ required: isEdit, message: '请填写单位佣金/返利' }]"
          />    <van-field
            v-model="contractDetail.taxCode"
            name="税码"
            label="税码"
            placeholder="税码"
            :rules="[{ required: isEdit, message: '请填写税码' }]"
          />    <van-field
            v-model="contractDetail.packSize"
            name="包装规格"
            label="包装规格"
            placeholder="包装规格"
            :rules="[{ required: isEdit, message: '请填写包装规格' }]"
          />    <van-field
            v-model="contractDetail.package"
            name="包装"
            label="包装"
            placeholder="包装"
            :rules="[{ required: isEdit, message: '请填写包装' }]"
          />    <van-field
            v-model="contractDetail.qualityStandard"
            name="质量标准"
            label="质量标准"
            placeholder="质量标准"
            :rules="[{ required: isEdit, message: '请填写质量标准' }]"
          />
          <van-field
            v-model="contractDetail.peripheralLib"
            name="外设库"
            label="外设库"
            placeholder="外设库"
            :rules="[{ required: isEdit, message: '请填写外设库' }]"
          />
          <van-field
            v-model="contractDetail.lineRemark"
            name="行备注"
            label="行备注"
            placeholder="行备注"
            :rules="[{ required: false, message: '请填写行备注' }]"
          />
        </div>
        </van-cell-group>
      </van-form>
      <van-divider/>
      <div style="margin: 16px">
        <van-button  type="primary" @click="saveLine(contractDetail)" style="margin-left: 0%; width: 25%;">保存</van-button>
        <van-button  type="primary" @click="pushLine(contractDetail)" style="margin-left: 10%; width: 25%;">下一行</van-button>
        <van-button  type="primary" @click="goBack()" style="margin-left: 10%; width: 25%;">返回</van-button>
      </div>
    </div>


  </template>

<script>
import {mapActions, mapMutations, mapState} from "vuex";

export default {
  data() {
    return {
      isEdit: false,
      contractDetail: {
        contractDetailNum: "",
        productSize: "", //产品规格
        quantity: "",
        unit: "",
        unitPrice: "",
        unitRebate: "", //单位佣金/返利
        taxCode: "",
        packSize: "", //包装规格
        package: "",
        qualityStandard: "",
        peripheralLib: "", //外设库
        lineRemark: "",
      }
    };
  },
  computed:{
    ...mapState({
      // contractDetail: state => state.ContractAbout.contractDetail,
      contractDetailList: state => state.ContractAbout.contract.contractDetailList
    })
  },
  methods:{
    saveLine(val){
      this.$router.push("contract")
      this.$store.dispatch("ContractAbout/save_line",val)
    },
    //保存合同行
    pushLine(val){
      this.$store.dispatch("ContractAbout/push_line",val)
      console.log(this.contractDetailList)
    },
    goBack(){
      this.$router.push("contract")
    },
    ...mapActions("ContractAbout",["save_line","push_line"]),
    ...mapMutations("ContractAbout",["SAVE_LINE","PUSH_LINE"])
  }
};
</script>

<style>
</style>
